/**
 * Event triggers collection.
 */
handlers = {
		
		originalChange: function(event) {
			$(this).data(namespace).repaintCaption();
		},
			
		wrapperMouseOver: function(event) {
			var data = $(this).data(namespace);
			data.caption.unbind('blur.' + namespace);
			data.arrow.addClass(data.options.classes.arrowHover);
		},
		
		wrapperMouseOut: function(event) {
			var data = $(this).data(namespace);
			data.caption.bind('blur.' + namespace, handlers.captionBlur);
			data.arrow.removeClass(data.options.classes.arrowHover);
		},
		
		wrapperMouseDown: function(event) {
			$(this).data(namespace).caption.focus();
		},
		
		wrapperMouseUp: function(event) {
			$(this).data(namespace).caption.focus();
		},
		
		captionMouseDown: function(event) {
			$(this).data(namespace).toggleMenu();
		},
		
		captionBlur: function(event) {
			$(this).data(namespace).collapseMenu();
		},
		
		captionKeyDown: function(event) {
			var data = $(this).data(namespace);
			switch (event.keyCode) {
			/* Enter */
			case 13:
				if (data.isMenuExpanded()) {
					data.collapseMenu(true);
				}
				break;
			/* Escape */
			case 27:
				data.collapseMenu();
				break;
			/* Page Up + Home */
			case 33:
			case 36:
				data.selectFirst();
				/* Prevent scrolling of document */
				event.preventDefault();
				break;
			/* Page Down + End */
			case 34:
			case 35:
				data.selectLast();
				/* Prevent scrolling of document */
				event.preventDefault();
				break;
			/* Arrow Up */
			case 38:
				if (event.altKey) {
					data.toggleMenu(true);
				} else {
					data.selectPrev();
					/* Prevent scrolling of document */
					event.preventDefault();
				}
				break;
			/* Arrow Down */
			case 40:
				if (event.altKey) {
					data.toggleMenu(true);
				} else {
					data.selectNext();
					/* Prevent scrolling of document */
					event.preventDefault();
				}
				break;
			/* F4 */
			case 115:
				data.toggleMenu(true);
				/* Prevent expanding address bar with recent history in IE */
				event.preventDefault();
				break;
			}
		},
		
		arrowMouseDown: function(event) {
			var data = $(this).data(namespace);
			data.toggleMenu();
			data.arrow.removeClass(data.options.classes.arrowHover).addClass(data.options.classes.arrowClick);
		},
		
		arrowMouseUp: function(event) {
			var data = $(this).data(namespace);
			data.arrow.removeClass(data.options.classes.arrowClick).addClass(data.options.classes.arrowHover);
		},
		
		itemMouseOver: function(event) {
			var $this = $(this), data = $this.data(namespace);
			data.clearHighlight();
			$this.addClass(data.options.classes.itemHover);
		},
		
		itemClick: function(event) {
			var $this = $(this), data = $this.data(namespace);
			data.selectItem($this);
			data.collapseMenu();
		},
		
		doNothing: function(event) {
			event.preventDefault();
		}
		
},

